package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnnouncementVo implements Serializable {
    private String id;
    private String title; //标题
    private String description; //描述
    private String createDate; //发布时间

    public static AnnouncementVo init(Announcement item) {
        AnnouncementVo vo = new AnnouncementVo();
        BeanUtils.copyProperties(item, vo);
        vo.setCreateDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.getCreated()));
        vo.setId(item.getId().toString());
        return vo;
    }
}
